<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta http-equiv="Cache-Control" content="no-siteapp"/>
    <link href="assets/css/bootstrap.min.css" rel="stylesheet"/>
    <link rel="stylesheet" href="css/style.css"/>
    <link href="assets/css/codemirror.css" rel="stylesheet">
    <link rel="stylesheet" href="assets/css/ace.min.css"/>
    <link rel="stylesheet" href="font/css/font-awesome.min.css"/>
    <!--[if lte IE 8]>
    <link rel="stylesheet" href="assets/css/ace-ie.min.css"/>
    <![endif]-->
    <script src="js/jquery-1.9.1.min.js"></script>
    <script src="assets/js/bootstrap.min.js"></script>
    <script type="text/javascript" src="Widget/Validform/5.3.2/Validform.min.js"></script>
    <script src="assets/js/typeahead-bs2.min.js"></script>
    <script src="assets/js/jquery.dataTables.min.js"></script>
    <script src="assets/js/jquery.dataTables.bootstrap.js"></script>
    <script src="assets/layer/layer.js" type="text/javascript"></script>
    <script src="js/lrtk.js" type="text/javascript"></script>
    <script src="assets/layer/layer.js" type="text/javascript"></script>
    <script src="assets/laydate/laydate.js" type="text/javascript"></script>
    <script type="text/javascript">
        function sub() {

            //如果全部输入正确返回成功  输入错误则输出提示
            if (loginnameCheck() && nameCheck() && sexCheck() && telCheck() && emailCheck() && pwdCheck() && pwdSure() && addressCheck() && birthdayCheck()) {
                alert('提交成功');

                location.reload();//刷新页面

                return true;
            } else {
                alert('你的输入有误，请按要求输入后再提交');
                return  false;
            }

        }
        //验证登录名字段
        function loginnameCheck(str) {
            let reg = /^[a-zA-Z0-9_]{3,16}$/;
            let loginname = $("#loginname").val();
            if (!reg.test(loginname) || loginname == '') {
                $(".loginname").html("<span class='red'>3-16位</span>");
                return false;
            } else {
                $(".loginname").text('√');
                return true;
            }
        }

        //验证姓名字段
        function nameCheck(str) {
            let reg = /^[\u4e00-\u9fa5]{2,4}$/;
            let name = $("#name").val();
            if (!reg.test(name) || name == '') {
                $(".name").html("<span class='red'>请输入2~4位中文</span>");
                return false;
            } else {
                $(".name").text('√');
                return true;
            }
        }

        //验证性别字段
        function sexCheck(str) {
            let reg = /^男$|^女&/;
            let sex = $("#sex").val();
            if (!reg.test(sex) || sex == '') {
                $(".sex").html("<span class='red'>从男或女中选择输入</span>")
                return false;
            } else {
                $(".sex").text('√');
                return true;
            }
        }

        //验证电话
        function telCheck(str) {
            let reg = /^\d{11}$/;
            let tel = $("#tel").val();
            if (!reg.test(tel) || tel == '') {
                $(".tel").html("<span class='red'>请输入11位电话号码</span>")
                return false;
            } else {
                $(".tel").text('√');
                return true;
            }
        }

        //验证地址
        function addressCheck(str) {
            let reg = /^[\u4E00-\u9FA5A-Za-z\d\-\_]{5,60}$/;
            let address = $("#adderss").val();
            if (!reg.test(address) || address == '') {
                $(".address").html("<span class='red'>请输入正确的地址</span>")
                return false;
            } else {
                $(".address").text('√')
                return true;
            }
        }

        //验证出生日期
        function birthdayCheck(str) {
            let reg = /^(([0-9]{3}[1-9]|[0-9]{2}[1-9][0-9]{1}|[0-9]{1}[1-9][0-9]{2}|[1-9][0-9]{3})-(((0[13578]|1[02])-(0[1-9]|[12][0-9]|3[01]))|((0[469]|11)-(0[1-9]|[12][0-9]|30))|(02-(0[1-9]|[1][0-9]|2[0-8]))))|((([0-9]{2})(0[48]|[2468][048]|[13579][26])|((0[48]|[2468][048]|[3579][26])00))-02-29)$/;
            let birthday = $("#birthday").val();
            if (!reg.test(birthday) || birthday == '') {
                $(".birthday").html("<span class='red'>请输入正确的出生日期</span>")
                return false;
            } else {
                $(".birthday").text('√')
                return true;
            }
        }

        //验证邮箱字段
        function emailCheck(str) {
            let reg = /^\w{3,12}@\w{1,5}\.[a-z]{2,3}$/;
            let email = $("#email").val();
            if (!reg.test(email) || email == '') {
                $(".email").html("<span class='red'>请输入正确的邮箱</span>")
                return false;
            } else {
                $(".email").text('√');
                return true;
            }
        }

        //验证密码字段
        function pwdCheck(str) {
            let reg = /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)[\s\S]{8,16}$/;
            let pwd = $("#pwd").val();
            if (!reg.test(pwd) || pwd == '') {
                $(".pwd").html("<span class='red'>8-16个字符，至少1个大写字母，1个小写字母和1个数字，其他可以是任意字符</span>")
                return false;
            } else {
                $(".pwd").text('√');
                return true;
            }
        }

        //确认密码
        function pwdSure() {
            if ($("#pwd").val() === $("#pwd1").val()) {
                $(".pwd1").text('√');
                return true;
            } else {
                $(".pwd1").html("<span class='red'>两次密码输入不一致</span>")
                return false;
            }
        }
        //修改验证
        function sub1() {

            //如果全部输入正确返回成功  输入错误则输出提示
            if (loginnameCheck1() && nameCheck1() && sexCheck1() && telCheck1() && emailCheck1() && pwdCheck1() && pwdSure1() && addressCheck1() && birthdayCheck1()) {
                alert('提交成功');

                location.reload();//刷新页面

                return true;
            } else {
                alert('你的输入有误，请按要求输入后再提交');
                return  false;
            }

        }
        //验证登录名字段
        function loginnameCheck1(str) {
            let reg = /^[a-zA-Z0-9_]{3,16}$/;
            let loginname1 = $("#loginname1").val();
            if (!reg.test(loginname1) || loginname1 == '') {
                $(".loginname1").html("<span class='red'>3-16位</span>");
                return false;
            } else {
                $(".loginname1").text('√');
                return true;
            }
        }

        //验证姓名字段
        function nameCheck1(str) {
            let reg = /^[\u4e00-\u9fa5]{2,4}$/;
            let name1 = $("#name1").val();
            if (!reg.test(name1) || name1 == '') {
                $(".name1").html("<span class='red'>请输入2~4位中文</span>");
                return false;
            } else {
                $(".name1").text('√');
                return true;
            }
        }

        //验证性别字段
        function sexCheck1(str) {
            let reg = /^男$|^女&/;
            let sex1 = $("#sex1").val();
            if (!reg.test(sex1) || sex1 == '') {
                $(".sex1").html("<span class='red'>从男或女中选择输入</span>")
                return false;
            } else {
                $(".sex1").text('√');
                return true;
            }
        }

        //验证电话
        function telCheck1(str) {
            let reg = /^\d{11}$/;
            let tel1 = $("#tel1").val();
            if (!reg.test(tel1) || tel == '') {
                $(".tel1").html("<span class='red'>请输入11位电话号码</span>")
                return false;
            } else {
                $(".tel1").text('√');
                return true;
            }
        }

        //验证地址
        function addressCheck1(str) {
            let reg = /^[\u4E00-\u9FA5A-Za-z\d\-\_]{5,60}$/;
            let address1 = $("#adderss1").val();
            if (!reg.test(address1) || address1 == '') {
                $(".address1").html("<span class='red'>请输入正确的地址</span>")
                return false;
            } else {
                $(".address1").text('√')
                return true;
            }
        }

        //验证出生日期
        function birthdayCheck1(str) {
            let reg = /^(([0-9]{3}[1-9]|[0-9]{2}[1-9][0-9]{1}|[0-9]{1}[1-9][0-9]{2}|[1-9][0-9]{3})-(((0[13578]|1[02])-(0[1-9]|[12][0-9]|3[01]))|((0[469]|11)-(0[1-9]|[12][0-9]|30))|(02-(0[1-9]|[1][0-9]|2[0-8]))))|((([0-9]{2})(0[48]|[2468][048]|[13579][26])|((0[48]|[2468][048]|[3579][26])00))-02-29)$/;
            let birthday1 = $("#birthday1").val();
            if (!reg.test(birthday1) || birthday1 == '') {
                $(".birthday1").html("<span class='red'>请输入正确的出生日期</span>")
                return false;
            } else {
                $(".birthday1").text('√')
                return true;
            }
        }

        //验证邮箱字段
        function emailCheck1(str) {
            let reg = /^\w{3,12}@\w{1,5}\.[a-z]{2,3}$/;
            let email1= $("#email1").val();
            if (!reg.test(email1) || email1 == '') {
                $(".email1").html("<span class='red'>请输入正确的邮箱</span>")
                return false;
            } else {
                $(".email1").text('√');
                return true;
            }
        }

        //验证密码字段
        function pwdCheck1(str) {
            let reg = /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)[\s\S]{8,16}$/;
            let pwd12 = $("#pwd12").val();
            if (!reg.test(pwd12) || pwd12 == '') {
                $(".pwd12").html("<span class='red'>8-16个字符，至少1个大写字母，1个小写字母和1个数字，其他可以是任意字符</span>")
                return false;
            } else {
                $(".pwd12").text('√');
                return true;
            }
        }

        //确认密码
        function pwdSure1() {
            if ($("#pwd12").val() === $("#pwd11").val()) {
                $(".pwd11").text('√');
                return true;
            } else {
                $(".pwd11").html("<span class='red'>两次密码输入不一致</span>")
                return false;
            }
        }

        /*拿到员工分类菜单*/
        $(function () {
            $.ajax({
                url: 'getAllAll',
                type: 'get',
                dataType: 'json',
                success: function (data) {
                    $('#show').html('');
                    $('.select').html('');/*添加员工---下拉框设置部门*/
                    $.each(data, function (i, item) {
                        $('#show').append('<li><i class="fa fa-users orange"></i> <a href="javascript:void(0)" onclick="change(' + item.did + ')">' + item.name + '</a></li>');
                        $('.select').append('<option value="' + item.did + '">' + item.name + '</option>');
                    })
                }
            })
        })

        /*点击不同部门后，跳转到不同部门的员工列表*/
        function change(eid) {
            $.ajax({
                url: '/changeDept',
                type: 'get',
                dataType: 'json',
                data: 'eid=' + eid,
                success: function (data) {
                    $('#content').html('');
                    $.each(data, function (i, item) {
                        alert(item.email);
                        $('#content').append('<tr>' +
                            '<td><label><input type="checkbox" name="flag" value="' + item.eid + '" class="ace"><span class="lbl"></span></label></td>' +
                            '<td>' + item.eid + '</td>' +
                            '<td>' + item.loginname + '</td>' +
                            '<td>' + item.pwd + '</td>' +
                            '<td>' + item.realname + '</td>' +
                            '<td>' + item.gender + '</td>' +
                            '<td>' + item.email + '</td>' +
                            '<td>' + item.phone + '</td>' +
                            '<td>' + item.address + '</td>' +
                            '<td>' + item.birthday + '</td>' +
                            '<td>' + item.dept.name + '</td>' +
                            '<td class="td-manage">' +
                            '<a title="编辑" onclick="empistrator_update(' + item.eid + ')" href="javascript:;"  class="btn btn-xs btn-info" ><i class="fa fa-edit bigger-120"></i></a>' +
                            '<a title="删除" href="javascript:;"  onclick="member_del(this,' + item.eid + ')" class="btn btn-xs btn-warning" ><i class="fa fa-trash  bigger-120"></i></a>' +
                            '</td>' +
                            '</tr>');
                    })
                }
            })
        }

        /*点击到其它角色列表后，再点击全部员工后可遍历全部员工*/
        function jump() {
            $.ajax({
                url: '/getAll1',
                type: 'get',
                dataType: 'json',
                success: function (data) {
                    $('#content').html('');
                    $.each(data, function (i, item) {
                        $('#content').append('<tr>' +
                            '<td><label><input type="checkbox" name="flag" value="' + item.eid + '" class="ace"><span class="lbl"></span></label></td>' +
                            '<td>' + item.eid + '</td>' +
                            '<td>' + item.loginname + '</td>' +
                            '<td>' + item.pwd + '</td>' +
                            '<td>' + item.realname + '</td>' +
                            '<td>' + item.gender + '</td>' +
                            '<td>' + item.email + '</td>' +
                            '<td>' + item.phone + '</td>' +
                            '<td>' + item.address + '</td>' +
                            '<td>' + item.birthday + '</td>' +
                            '<td>' + item.dept.name + '</td>' +
                            '<td class="td-manage">' +
                            '<a title="编辑" onclick="empistrator_update(' + item.eid + ')" href="javascript:;"  class="btn btn-xs btn-info" ><i class="fa fa-edit bigger-120"></i></a>' +
                            '<a title="删除" href="javascript:;"  onclick="member_del(this,' + item.eid + ')" class="btn btn-xs btn-warning" ><i class="fa fa-trash  bigger-120"></i></a>' +
                            '</td>' +
                            '</tr>');
                    })
                }
            })
        }

        /*批量删除员工*/
        function deleteemp() {
            var obj = document.getElementsByName("flag");/*拿到所有name=flag的对象*/
            var result = $("input[type='checkbox']").is(':checked');
            if (result == false) {
                return alert('请点击复选框在进行操作');
            }
            var s = "";
            for (var i = 0; i < obj.length; i++) {
                if (obj[i].checked) {
                    s += obj[i].value + ",";
                }
            }
            ;
            $.ajax({
                url: '/delSome1',
                type: 'get',
                dataType: 'json',
                data: 'ids=' + s,
                success: function (data) {
                    if (data >= 1) {
                        window.location.reload();
                    }
                }
            })
        }
    </script>
    <title>员工</title>
</head>


<body class="page-content clearfix">
<div class="empistrator">
    <div class="d_Confirm_Order_style">
        <div class="search_style">
            <ul class="search_content clearfix">
                <li><label class="l_f">员工名称</label><input name="" type="text" class="text_add" placeholder=""
                                                          style=" width:400px"/></li>
                <li><label class="l_f">添加时间</label><input class="inline laydate-icon" id="start"
                                                          style=" margin-left:10px;"></li>
                <li style="width:90px;">
                    <button type="button" class="btn_search"><i class="fa fa-search"></i>查询</button>
                </li>
            </ul>
        </div>
        <!--操作-->
        <div class="border clearfix">
       <span class="l_f">
        <a href="javascript:void(0)" id="empistrator_add" class="btn btn-warning"><i class="fa fa-plus"></i> 添加员工</a>
        <a href="javascript:void(0)" onclick="deleteemp()" class="btn btn-danger"><i class="fa fa-trash"></i> 批量删除</a>
       </span>
            <span class="r_f">共：<b th:text="${count}"></b>人</span>
        </div>
        <!--员工列表-->
        <div class="clearfix administrator_style" id="administrator">
            <div class="left_style">
                <div id="scrollsidebar" class="left_Treeview">
                    <div class="show_btn" id="rightArrow"><span></span></div>
                   <div class="widget-box side_content">
                        <div class="side_title"><a title="隐藏" class="close_btn"><span></span></a></div>
                        <div class="side_list">
                            <div class="widget-header header-color-green2"><h4 class="lighter smaller">员工分类列表</h4></div>
                            <div class="widget-body">
                                <ul class="b_P_Sort_list">
                                    <li><i class="fa fa-users green"></i> <a href="javascript:void(0)" onclick="jump()">全部员工</a>
                                    </li>
                                    <div id="show">
                                        <li><i class="fa fa-users orange"></i> <a href="#"></a></li>
                                    </div>
                                    <!--<li><i class="fa fa-users orange"></i> <a href="#">普通管理员（5）</a></li>
                                    <li><i class="fa fa-users orange"></i> <a href="#">产品编辑管理员（4）</a></li>
                                    <li><i class="fa fa-users orange"></i> <a href="#">管理员（1）</a></li>-->
                                </ul>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="table_menu_list" id="testIframe" style="width: 100%">
                <table class="table table-striped table-bordered table-hover" id="sample_table">
                    <thead>
                    <tr>
                        <th width="25px"><label><input type="checkbox" class="ace"><span class="lbl"></span></label>
                        </th>
                        <th>ID</th>
                        <th>登录名称</th>
                        <th>登录密码</th>
                        <th>员工名字</th>
                        <th>性别</th>
                        <th>邮箱</th>
                        <th>电话</th>
                        <th>地址</th>
                        <th>生日</th>
                        <th>部门</th>
                        <th>操作</th>
                    </tr>
                    </thead>
                    <tbody id="content">
                    <tr th:each="emp:${emps}">
                        <td><label><input type="checkbox" th:value="${emp.eid}" name="flag" class="ace"><span
                                class="lbl"></span></label></td>
                        <td th:text="${emp.eid}"></td>
                        <td th:text="${emp.loginname}"></td>
                        <td th:text="${emp.pwd}"></td>
                        <td th:text="${emp.realname}"></td>
                        <td th:text="${emp.gender}"></td>
                        <td th:text="${emp.email}"></td>
                        <td th:text="${emp.phone}"></td>
                        <td th:text="${emp.address}"></td>
                        <td th:text="${#dates.format(emp.birthday,'yyyy-MM-dd')}"></td>
                        <td th:text="${emp.dept.name}"></td>
                        <!--<td>2016-6-29 12:34</td>-->
                        <td class="td-manage">
                            <a title="编辑" th:onclick="'empistrator_update('+${emp.eid}+');'" href="javascript:;"
                               class="btn btn-xs btn-info"><i class="fa fa-edit bigger-120"></i></a>
                            <a title="删除" href="javascript:;" th:onclick="member_del(this,[[${emp.eid}]]);"
                               class="btn btn-xs btn-warning"><i class="fa fa-trash  bigger-120"></i></a>
                        </td>
                    </tr>
                    <!--<tr>
                        <td><label><input type="checkbox" class="ace"><span class="lbl"></span></label></td>
                        <td>2</td>
                        <td>admin12345</td>
                        <td>18934334544</td>
                        <td>2345454@qq.com</td>
                        <td>管理员</td>
                        <td>2016-6-29 12:34</td>
                        <td class="td-status"><span class="label label-success radius">已启用</span></td>
                        <td class="td-manage">
                            <a onClick="member_stop(this,'10001')"  href="javascript:;" title="停用"  class="btn btn-xs btn-success"><i class="fa fa-check  bigger-120"></i></a>
                            <a title="编辑" onclick="member_edit('编辑','member-add.html','4','','510')" href="javascript:;"  class="btn btn-xs btn-info" ><i class="fa fa-edit bigger-120"></i></a>
                            <a title="删除" href="javascript:;"  onclick="member_del(this,'1')" class="btn btn-xs btn-warning" ><i class="fa fa-trash  bigger-120"></i></a>
                        </td>
                    </tr>-->
                    </tbody>
                </table>
            </div>
        </div>
    </div>
</div>
<!--添加员工-->
<div id="add_administrator_style" class="add_menber" style="display:none">
        <div class="content">
            <form th:action="@{/addEmp}" onsubmit="return sub()" method="post">
                <p>
                    <label for="loginname">登录名：</label>
                    <input type="text" id="loginname" onblur="loginnameCheck()" name="loginname" >
                    <span class="loginname">3-16位</span>
                </p>
                <p>
                    <label for="pwd">密码：</label>
                    <input type="password" id="pwd" onblur="pwdCheck()" name="pwd">
                    <span class="pwd">8-16位密码</span>
                </p>
                <p>
                    <label for="pwd1">密码确认：</label>
                    <input type="password" id="pwd1" onblur="pwdSure()" >
                    <span class="pwd1">请再次输入密码</span>
                </p>
                <p>
                    <label for="name">真实名：</label>
                    <input type="text" id="name" onblur="nameCheck()" name="realname">
                    <span class="name">2-4位中文组成</span>
                </p>
                <p>
                    <label for="sex">性别：</label>
                    <input type="text" id="sex" onblur="sexCheck()" name="gender">
                    <span class="sex">请输入男或女</span>
                </p>
                <p>
                    <label for="email">邮箱：</label>
                    <input type="email" id="email" onblur="emailCheck()" name="email">
                    <span class="email">ex:123456@qq.com</span>
                </p>
                <p>
                    <label for="tel">电话：</label>
                    <input type="text" id="tel" onblur="telCheck()" name="phone">
                    <span class="tel">11位数字组成</span>
                </p>
                <p>
                    <label for="address">地址：</label>
                    <input type="text" id="address" onblur="addressCheck()" name="address">
                    <span class="address"> 家庭详细地址</span>
                </p>
                <p>
                    <label for="birthday">出生日期：</label>
                    <input type="date" id="birthday" onblur="birthdayCheck()" name="birthday">
                    <span class="birthday">ex:1999-10-10</span>
                </p>


                <div class="form-group">
                    <label class="form-label">部门：</label>
                    <div class="formControls "> <span class="select-box" style="width:150px;">
				            <select class="select" name="dept.did" size="1">
<!--					            <option value="1">光之巨人</option>-->
<!--					            <option value="2">dnf</option>-->
<!--                                <option value="3">峡谷之巅</option>-->
<!--					            <option value="4">云顶</option>-->
                              <option th:each="dept:${depts}" th:text="${dept.name}" th:value="${dept.did}"></option>
				</select>
				</span>
                    </div>
                </div>
                <p class="content">
                    <input type="submit"  id="submit" value="提交">
                </p>
            </form>

    </div>

</div>
<!--修改员工-->
<div id="update_administrator_style" class="add_menber" style="display:none">
    <div class="content">
        <form th:action="@{/updateEmpReal}" onsubmit="return sub1()" method="post">
            <input type="hidden" value="" name="eid">
            <p>
                <label for="loginname1">登录名：</label>
                <input type="text" id="loginname1" onblur="loginnameCheck1()" name="loginname" >
                <span class="loginname1">3-16位</span>
            </p>
            <p>
                <label for="pwd12">密码：</label>
                <input type="password" id="pwd12" onblur="pwdCheck1()" name="pwd">
                <span class="pwd12">8-16位密码</span>
            </p>
            <p>
                <label for="pwd11">密码确认：</label>
                <input type="password" id="pwd11" onblur="pwdSure1()" >
                <span class="pwd11">请再次输入密码</span>
            </p>
            <p>
                <label for="name1">真实名：</label>
                <input type="text" id="name1" onblur="nameCheck1()" name="realname">
                <span class="name1">2-4位中文组成</span>
            </p>
            <p>
                <label for="sex1">性别：</label>
                <input type="text" id="sex1" onblur="sexCheck1()" name="gender">
                <span class="sex1">请输入男或女</span>
            </p>
            <p>
                <label for="email1">邮箱：</label>
                <input type="email" id="email1" onblur="emailCheck1()" name="email">
                <span class="email1">ex:123456@qq.com</span>
            </p>
            <p>
                <label for="tel1">电话：</label>
                <input type="text" id="tel1" onblur="telCheck1()" name="phone">
                <span class="tel1">11位数字组成</span>
            </p>
            <p>
                <label for="address1">地址：</label>
                <input type="text" id="address1" onblur="addressCheck1()" name="address">
                <span class="address1"> 家庭详细地址</span>
            </p>
            <p>
                <label for="birthday1">出生日期：</label>
                <input type="date" id="birthday1" onblur="birthdayCheck1()" name="birthday">
                <span class="birthday1">ex:1999-10-10</span>
            </p>


            <div class="form-group">
                <label class="form-label">部门：</label>
                <div class="formControls "> <span class="select-box" style="width:150px;">
				            <select class="select" name="dept.did" size="1">
<!--					            <option value="1">光之巨人</option>-->
<!--					            <option value="2">dnf</option>-->
<!--                                <option value="3">峡谷之巅</option>-->
<!--					            <option value="4">云顶</option>-->
                                <option th:each="dept:${depts}" th:text="${dept.name}" th:value="${dept.did}"></option>
				</select>
				</span>
                </div>
            </div>
            <p class="content">
                <input type="submit"  id="submit1" value="提交">
            </p>
        </form>
</div>

</div>

</body>

<script type="text/javascript" th:inline="none">
    jQuery(function ($) {
        var oTable1 = $('#sample_table').dataTable({
            "aaSorting": [[1, "desc"]],//默认第几个排序
            "bStateSave": true,//状态保存
            "aoColumnDefs": [
                //{"bVisible": false, "aTargets": [ 3 ]} //控制列的隐藏显示
                {"orderable": false, "aTargets": [0]}// 制定列不参与排序
            ]
        });


        $('table th input:checkbox').on('click', function () {
            var that = this;
            $(this).closest('table').find('tr > td:first-child input:checkbox')
                .each(function () {
                    this.checked = that.checked;
                    $(this).closest('tr').toggleClass('selected');
                });

        });


        $('[data-rel="tooltip"]').tooltip({placement: tooltip_placement});

        function tooltip_placement(context, source) {
            var $source = $(source);
            var $parent = $source.closest('table')
            var off1 = $parent.offset();
            var w1 = $parent.width();

            var off2 = $source.offset();
            var w2 = $source.width();

            if (parseInt(off2.left) < parseInt(off1.left) + parseInt(w1 / 2)) return 'right';
            return 'left';
        }
    });

</script>
<script type="text/javascript">
    $(function () {
        $("#administrator").fix({
            float: 'left',
            //minStatue : true,
            skin: 'green',
            durationTime: false,
            spacingw: 50,//设置隐藏时的距离
            spacingh: 270,//设置显示时间距
        });
    });

    //字数限制
    function checkLength(which) {
        var maxChars = 100; //
        if (which.value.length > maxChars) {
            layer.open({
                icon: 2,
                title: '提示框',
                content: '您输入的字数超过限制!',
            });
            // 超过限制的字数了就将 文本框中的内容按规定的字数 截取
            which.value = which.value.substring(0, maxChars);
            return false;
        } else {
            var curr = maxChars - which.value.length; //250 减去 当前输入的
            document.getElementById("sy").innerHTML = curr.toString();
            return true;
        }
    };

    //初始化宽度、高度
    $(".widget-box").height($(window).height() - 215);
    $(".table_menu_list").width($(window).width() - 260);
    $(".table_menu_list").height($(window).height() - 215);
    //当文档窗口发生改变时 触发
    $(window).resize(function () {
        $(".widget-box").height($(window).height() - 215);
        $(".table_menu_list").width($(window).width() - 260);
        $(".table_menu_list").height($(window).height() - 215);
    })
    laydate({
        elem: '#start',
        event: 'focus'
    });

    /*用户-停用*/
    /*   function member_stop(obj,id){
           layer.confirm('确认要停用吗？',function(index){
               $(obj).parents("tr").find(".td-manage").prepend('<a style="text-decoration:none" class="btn btn-xs " onClick="member_start(this,id)" href="javascript:;" title="启用"><i class="fa fa-close bigger-120"></i></a>');
               $(obj).parents("tr").find(".td-status").html('<span class="label label-defaunt radius">已停用</span>');
               $(obj).remove();
               layer.msg('已停用!',{icon: 5,time:1000});
           });
       }*/
    /*用户-启用*/
    /*    function member_start(obj,id){
            layer.confirm('确认要启用吗？',function(index){
                $(obj).parents("tr").find(".td-manage").prepend('<a style="text-decoration:none" class="btn btn-xs btn-success" onClick="member_stop(this,id)" href="javascript:;" title="停用"><i class="fa fa-check  bigger-120"></i></a>');
                $(obj).parents("tr").find(".td-status").html('<span class="label label-success radius">已启用</span>');
                $(obj).remove();
                layer.msg('已启用!',{icon: 6,time:1000});
            });
        }*/
    /*产品-编辑*/
    /*   function member_edit(title,url,id,w,h){
           layer_show(title,url,w,h);
       }*/


    /*员工-删除*/
    function member_del(obj, eid) {

        layer.confirm('确认要删除吗？', function (index) {
            $.ajax({
                url: '/del1',
                type: 'get',
                dataType: 'json',
                data: 'eid=' + eid,
                success: function (data) {
                    $(obj).parents("tr").remove();
                    layer.msg('已删除!', {icon: 1, time: 1000});
                }
            })
        });
    }

    /*修改员工*/
    function empistrator_update(eid) {


        $.ajax({
            url: '/updateEmp',
            type: 'get',
            dataType: 'json',
            data: 'eid=' + eid,
            success: function (data) {
                layer.open({
                    type: 1,
                    title: '修改员工',
                    area: ['700px', ''],
                    shadeClose: false,
                    content: $('#update_administrator_style'),
                });

                $('input[type=hidden]').val(data.eid);
                $('#loginname1').val(data.loginname);
                $('#pwd12').val(data.pwd);
                $('#pwd11').val(data.pwd);
                $('#name1').val(data.realname);
                $('#sex1').val(data.gender);
                $('#tel1').val(data.phone);
                $('#email1').val(data.email);
                $('#address1').val(data.address);
                $('#birthday1').val(date.birthday);
                $('option[value="' + data.dept.did + '"]').attr("selected", true);


            }
        })
    }

    /*添加员工*/
    $('#empistrator_add').on('click', function () {
        layer.open({
            type: 1,
            title: '添加员工',
            area: ['700px', ''],
            shadeClose: false,
            content: $('#add_administrator_style'),

        });
    })
    //表单验证提交
    /*   $("#form-admin-add").Validform({

           tiptype:2,

           callback:function(data){
               //form[0].submit();
               if(data.status==1){
                   layer.msg(data.info, {icon: data.status,time: 1000}, function(){
                       location.reload();//刷新页面
                   });
               }
               else{
                   layer.msg(data.info, {icon: data.status,time: 3000});
               }
               var index =parent.$("#iframe").attr("src");
               parent.layer.close(index);

           }


       });*/

</script>

</html>
